Summit.UI.Widget.Banner = function()
{
	var self = this;

	this.el = {};
	this.el.div = new Element('div',{'class':'Banner'});
	this.el.div.fx = new Fx.Styles(this.el.div, {duration: 750,	wait: false, transition: Fx.Transitions.Quad.easeOut});
	this.loaded = false;
	this.isOpen = false;
	this.timeout = false;
	this.closeTimeout = false;

	this.open = function(text,timeout)
	{
		if(!self.loaded)
		{
			self.el.div.injectInside(document.body);
			self.loaded=true;
		}

		if(!self.isOpen)
		{
			self.el.div.setHTML(text);
			var height = self.el.div.offsetHeight;
			self.el.div.fx.start({
			'bottom':[-height,0],
			'opacity':1
			}).chain(function(){
				self.isOpen=true
			});
		}
		else
		{
			self.el.div.fx.start({'background-color':['#1E90FF','#00BFFF'],'opacity':.25});
			
			if(self.timeout)
			{
				clearTimeout(self.timeout)
				self.timeout=false;
			}
			
			self.timeout=setTimeout(function()
			{
					self.el.div.setHTML(text);
					self.el.div.fx.start({'background-color':['#00BFFF','#1E90FF'],'opacity':1});
					self.timeout=false;
			},500);	
		}
		
		if(self.closeTimeout)
		clearTimeout(self.closeTimeout)
		
		if(timeout)
		self.closeTimeout = setTimeout(self.close,timeout*1000)
	}

	this.close = function()
	{
		if(self.closeTimeout)
		clearTimeout(self.closeTimeout)
		
		var height = self.el.div.offsetHeight;
		self.el.div.fx.start({
		'bottom':[0,-height],
		'opacity':.5
		}).chain(function(){self.isOpen=false;})
	}
}

window.banner = new Summit.UI.Widget.Banner;